import React, { Component } from 'react';
import queryStr from 'querystring'

export default class Detail extends Component {
    state={details:
        [
            {id:"1",title:"message001",content:"001 内容"},
            {id:"2",title:"message002",content:"002 内容"},
            {id:"3",title:"message003",content:"003 内容"}
        ]
    }
    render() {
        const {id,title}=this.props.location.state
        // const {id,title}=this.props.match.params;
        // const {search}=this.props.location
        // const {id,title}=queryStr.parse(search.slice(1));
        const {details}=this.state
        const detail=details.find((cur)=>{
            return cur.id===id;
        })
        console.log(detail);
        return (
            <div>
                <ul>
                    <li>ID:{id}</li>
                    <li>Title:{title}</li>
                    <li>Content:{detail.content}</li>
                </ul>
            </div>
        );
    }
}
